package com.ccntec.spark.core.tags.html;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.ccntec.spark.core.util.StringUtil;

public class LabTag extends TagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6391344422544149161L;
	private String forId ;
	private String label;
	private String style ;
	
	@Override
	public int doStartTag() throws JspException {
		//String html = "<label class="control-label col-md-2" for=""></label>"; 
		StringBuffer html = new StringBuffer();
		html.append("<label ");
		if(StringUtil.isNull(style)){
			html.append("class=\"control-label col-md-2\" ");
		}else{
			html.append("class=\""+style+"\" ");
		}
		html.append("for=\""+forId+"\" >"+label+"</label>");
		try {
			pageContext.getOut().print(html);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}
	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}
	@Override
	public void release() {
		super.release();
	}
	public void setForId(String forId) {
		this.forId = forId;
	}
	public void setLabel(String label) {
		this.label = label;
	}
	public void setStyle(String style) {
		this.style = style;
	}
	
}
